package com.rizzo.web.security;

import java.io.Serializable;

/**
 * A simple mapping POJO that contains name-url key-values.
 *
 * @author jalieven
 */
public class Function implements Serializable {

    private static final long serialVersionUID = -6298546280288918933L;

    private String name;
    private String url;
    private String panel;

    // Constructor
    public Function(String name, String url, String panel) {
        this.name = name;
        this.url = url;
        this.panel = panel;
    }

    /**
     * Getter for property 'name'.
     *
     * @return Value for property 'name'.
     */
    public String getName() {
        return name;
    }

    /**
     * Setter for property 'name'.
     *
     * @param name Value to set for property 'name'.
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * Getter for property 'url'.
     *
     * @return Value for property 'url'.
     */
    public String getUrl() {
        return url;
    }

    /**
     * Setter for property 'url'.
     *
     * @param url Value to set for property 'url'.
     */
    public void setUrl(String url) {
        this.url = url;
    }

    /**
     * Getter for property 'panel'.
     *
     * @return Value for property 'panel'.
     */
    public String getPanel() {
        return panel;
    }

    /**
     * Setter for property 'panel'.
     *
     * @param panel Value to set for property 'panel'.
     */
    public void setPanel(String panel) {
        this.panel = panel;
    }

    /**
     * {@inheritDoc}
     */
    public int hashCode() {
        int retValue = super.hashCode();
        if (this.getName() != null) {
            retValue ^= this.getName().hashCode();
        }
        if (this.getUrl() != null) {
            retValue ^= this.getUrl().hashCode();
        }
        if (this.getPanel() != null) {
            retValue ^= this.getPanel().hashCode();
        }
        return retValue;
    }

    /**
     * {@inheritDoc}
     */
    public boolean equals(Object o) {
        boolean retValue = false;
        if (o instanceof Function) {
            Function function = (Function) o;
            if (function.getName() != null && function.getUrl() != null && function.getPanel() != null) {
                if (function.getName().equals(this.getName()) &&
                        function.getUrl().equals(this.getUrl()) &&
                        function.getPanel().equals(this.getPanel())) {
                    retValue = true;
                }
            }
        }
        return retValue;
    }
}
